import Vue from 'vue'

export default {

  create(data) {
    return new Promise((resolve, reject) => {
      Vue.axios.post('/role', data).then(response => {
        resolve(response.data)
      })
    })
  },

  delete(id) {
    return new Promise((resolve, reject) => {
      Vue.axios.delete('/role/' + id).then(response => {
        resolve(response.data)
      })
    })
  },

  deleteUser(id, uid) {
    return new Promise((resolve, reject) => {
      Vue.axios.delete('/role/' + id, {params: {uid: uid}}).then(response => {
        resolve(response.data)
      })
    })
  },

  addUser(data) {
    return new Promise((resolve, reject) => {
      Vue.axios.post('/role', data).then(response => {
        resolve(response.data)
      })
    })
  },

  getList(map) {
    return new Promise((resolve, reject) => {
      Vue.axios.get('/role', {params: map}).then(response => {
        resolve(response.data)
      })
    })
  },

  getInfo(id, map = {}) {
    //查询参数可以指定member=1查询会员信息，而不是用户本身的信息
    return new Promise((resolve, reject) => {
      Vue.axios.get('/role/' + id, {params: map}).then(response => {
        resolve(response.data)
      })
    })
  },

  //更新用户基本信息
  update(id, data) {
    return new Promise((resolve, reject) => {
      Vue.axios.put('/role/' + id, data).then(response => {
        resolve(response.data)
      })
    })
  },

}
